<?php
declare(strict_types=1);

use app\admin\middleware\Jwt;
use think\facade\Request;
use think\facade\Route;

// 获取sign表示
$header_info = Request::header();

// 登录
Route::any('/admin/login', '\app\admin\controller\Login@login');
// swagger
Route::get('/swagger', '\app\admin\controller\Swagger@index');

if (isset($header_info['token'])) {

    Route::domain($header_info['host'], function () {


        Route::group(function () {
            // 用户
            Route::get('/admin/member/list', '\app\admin\controller\Member@list');
            Route::post('/member/save', '\app\admin\controller\Member@save');
            Route::get('/member/read', '\app\admin\controller\Member@read');
            Route::post('/member/update_member_level', '\app\admin\controller\Member@update_member_level');

            // 用户
            Route::get('/bill/list', '\app\admin\controller\Bill@list');
        })->middleware(Jwt::class);
    });
} else {
    // 异常
    Route::miss(function () {
        return '404 Not Found!';
    });
}
